﻿// --------------------------------------------------------------------------------------------------------------------- 
// <copyright file="GetNextTrendByIdTest.cs" company="Scrum for Team System">
//   None
// </copyright>
// <summary>
//   Defines the GetNextTrendByIdTest type.
// </summary>
// ---------------------------------------------------------------------------------------------------------------------
namespace ScrumForTeamSystem.Metrics.Test
{
    using System;

    using Microsoft.VisualStudio.TestTools.UnitTesting;

    /// <summary>
    /// Defines the GetNextTrendByIdTest type.
    /// </summary>
    [TestClass]
    public class GetNextTrendByIdTest
    {
        /// <summary>
        /// test to prove that: Trying to forecast with an invalid trend type id should throw an argument out of range exception.
        /// </summary>
        [TestMethod]
        public void Trying_to_forecast_with_an_invalid_trend_type_id_should_throw_an_argument_out_of_range_exception()
        {
            var hasThrownException = false;

            try
            {
                var forecast = new Forecasting();

                forecast.GetNextTrendValue(1000, false, "100,90,80,70,,,,,");
            }
            catch (ArgumentOutOfRangeException)
            {
                hasThrownException = true;
            }

            Assert.IsTrue(hasThrownException);
        }

        /// <summary>
        /// test to prove that: Trying to forecast with a valid trend type id should not throw an argument out of range exception.
        /// </summary>
        [TestMethod]
        public void Trying_to_forecast_with_a_valid_trend_type_id_should_not_throw_an_argument_out_of_range_exception()
        {
            var hasThrownException = false;

            try
            {
                foreach (var trendType in Enum.GetValues(typeof(TrendType)))
                {
                    var trendTypeId = (int)trendType;
                    
                    var forecast = new Forecasting();

                    forecast.GetNextTrendValue(trendTypeId, false, "100,90,80,70,,,,,");
                }
            }
            catch (ArgumentOutOfRangeException)
            {
                hasThrownException = true;
            }

            Assert.IsFalse(hasThrownException);
        }
    }
}
